package com.tuanzi.loan.business.entity.galaxycard;

import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
import javax.persistence.*;

import com.tuanzi.loan.business.constants.galaxycard.PrivilgeStatusConst;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 银河黑卡用户权益信息 Entity
 * @author JinRuiyang 2018/1/9 14:27:30
 */
@Data
@Entity
@Table(name = "loan_galaxy_card_privilege_info")
@SuppressWarnings("serial")
@EqualsAndHashCode
public class GalaxyCardUserPrivilege implements Serializable {

    // 主键
    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    // 用户卡信息id
    @Column(name = "card_info_id")
    private Long cardInfoId;

    // 对应卡权益id
    @Column(name = "privilege_id")
    private Long privilegeId;

    // 权益业务id
    @Column(name = "business_id")
    private Long businessId;

    // 权益处理器对应编码
    @Column(name = "code")
    private String code;

    // 卡权益状态值
    @Column(name = "privilege_status")
    private Integer privilegeStatus;

    // 创建时间
    @Column(name = "create_time")
    private Date createTime;

    // 更新时间
    @Column(name = "update_time")
    private Date updateTime;

    // 权益的快递信息id
    @Column(name = "express_id")
    private Long expressId;

    public Boolean canSendExpress(){
        return Objects.nonNull(this.expressId) && this.getPrivilegeStatus() == PrivilgeStatusConst.ACTIVING_WAIT_EXPRESS.val();
    }

    public Boolean canAddExpress(){
        return Objects.isNull(this.expressId) && this.getPrivilegeStatus() == PrivilgeStatusConst.ACTIVING_WAIT_INPUT.val();
    }
}
